import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getxdemo/get/get_commen_view.dart';
import 'package:getxdemo/ui/button/filled_button.dart';
import 'package:getxdemo/widget/login_edit.dart';
import 'package:getxdemo/widget/logo_name.dart';
import 'package:getxdemo/widget/toolbar.dart';

import '../../../res/r.dart';
import 'logic.dart';

class LoginPage extends GetCommonView<LoginLogic> {
  const LoginPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: true,
      body:  Container(
          width: double.infinity,
          height: double.infinity,
          decoration: const BoxDecoration(
              image: DecorationImage(
                  image: AssetImage(R.assetsImagesLoginBackground),
                  fit: BoxFit.cover)),
          child: SingleChildScrollView(
            child: Column(
              children: [
                 Toolbar(
                  title: "登录",
                  backgroundColor: Colors.white.withOpacity(0.5),
                ),

                /// logo
                const LoginName(),
                LoginEditWidget(
                    margin: const EdgeInsets.only(
                        top: 28, bottom: 8, left: 25, right: 25),
                    hint: "输入账号",
                    valueChanged: (value) => controller
                      ..userCount = value
                      ..update()),
                LoginEditWidget(
                    hint: "输入密码",
                    isPassWord: true,
                    valueChanged: (value) {
                      controller
                        ..passWord = value
                        ..update();
                    }),
                NormalButton(
                  margin: const EdgeInsets.only(left: 25, right: 25, top: 200),
                  height: 40,
                  width: 200,
                  fontSize: 14,
                  enable: controller.inputEnable,
                  onPressed: () {
                    controller.login();
                  },
                  title: "登录",
                )
              ],
            ),
          ),
        ),
    );
  }
}
